package org.crl.blogsystem.service;

import org.crl.blogsystem.entity.Media;
import org.crl.blogsystem.entity.dto.MediaDTO;
import org.crl.blogsystem.repository.MediaRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MediaService implements IMediaService {
    @Autowired
    MediaRepository mediaRepository;

    public MediaDTO save(Media media) {
        mediaRepository.save(media);
        return new MediaDTO(media.getId(), media.getBlog().getId(), media.getUrl());
    }
}
